package visualizer.drawable.transition;

import processing.core.PGraphics;
import visualizer.drawable.Drawable;

public class HorizontalScrollTransition extends AbstractTransition {
	public HorizontalScrollTransition(Drawable from, Drawable to, int steps) {
		super(from, to, steps);
	}

	public void drawFrom(PGraphics g) {
		drawAtHorizontalPosition(g, getFrom(), getCompletionPercentage());
	}
	
	public void drawTo(PGraphics g) {
		drawAtHorizontalPosition(g, getTo(), getCompletionPercentage() - 1);
	}
	
	public void drawAtHorizontalPosition(PGraphics g, Drawable d, double position)
	{
		if (d != null) {
			g.pushMatrix();
			g.translate((float) (g.width * position), (float) 0);
			d.draw(g);
			g.popMatrix();
		}
	}
}
